package org.dl.gjz.menyj.conf;

import jakarta.servlet.FilterRegistration;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import org.camunda.bpm.engine.rest.security.auth.ProcessEngineAuthenticationFilter;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AuthFilterConfig implements ServletContextInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        // ProcessEngineAuthenticationFilter 默认过滤器
        FilterRegistration.Dynamic authFIlter =
                servletContext.addFilter("camunda-authFilter", new ProcessEngineAuthenticationFilter());
        authFIlter.setAsyncSupported(true);
        authFIlter.setInitParameter(
                "authentication-provider", "org.camunda.bpm.engine.rest.security.auth.impl.HttpBasicAuthenticationProvider");
        authFIlter.addMappingForUrlPatterns(null, true, "/server1/engine-rest/*");
    }
}
